Skip to content

Simplify Windows read-only file deletion#200

Merged
NejcS merged 1 commit into
mainfrom
impr/simplify-windows-readonly-deletion
May 28, 2026
Merged

Simplify Windows read-only file deletion#200
NejcS merged 1 commit into
mainfrom
impr/simplify-windows-readonly-deletion

Conversation

@NejcS

@NejcS NejcS commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace hand-rolled os.walk + _make_writable logic with shutil.rmtree's built-in onerror handler
  • Uses the standard Python pattern for handling read-only .git/objects files on Windows
  • Removes the TODO comment requesting a cleaner approach

Relates to https://github.com/Codeplain-ai/next-microsoft/issues/5 (point 2: investigate if folders can be created with proper permissions instead of using make_writable).

Test plan

  • All tests pass (125 tests)
  • Pre-push checks pass (black, isort, flake8, mypy)
  • Tested on a Windows machine

@NejcS NejcS requested a review from VitjanZ May 25, 2026 12:40
@NejcS NejcS self-assigned this May 25, 2026
Comment thread file_utils.py
try:
os.remove(entry.path)
except PermissionError:
os.chmod(entry.path, stat.S_IWRITE)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the permissions weren't the reason the os.remove fails then this causes the process to crash?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess it would cause the process to crash if there's a different reason. But that would happen now too and we can handle that when we find such a case. Nice find though.

@NejcS NejcS merged commit c874017 into main May 28, 2026
10 checks passed
@NejcS NejcS deleted the impr/simplify-windows-readonly-deletion branch May 28, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants